package com.yootk.initializer;

import com.yootk.servlet.HelloServlet;
import jakarta.servlet.ServletContainerInitializer;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRegistration;
import jakarta.servlet.annotation.HandlesTypes;

import java.util.Set;

/**
 * 初始化管理类
 */
@HandlesTypes({HelloServlet.class}) // 必须在此处配置允许自动初始化的Servlet名称
public class WebApplicationInitializer implements ServletContainerInitializer {

    @Override
    public void onStartup(Set<Class<?>> set, ServletContext servletContext) throws ServletException {
        ServletRegistration.Dynamic registration = servletContext.addServlet("HelloServlet", "com.yootk.servlet.HelloServlet");
        registration.addMapping("/hello.action");
    }
}
